package com.guoliang.wechatpushing.controller;

import com.guoliang.wechatpushing.service.SendMessageService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * @author ：Leo
 * @date ：Created in 2022/10/18 20:27
 * @description：
 */
@Controller
public class MessageController {
    @Autowired
    SendMessageService sendMessageService;

    @Scheduled(cron = "0 30 7 ? * *")
    @RequestMapping("/sendMessage")
    @ResponseBody
    public String sendMessage(){
       if ( sendMessageService.sendMessage()){
           return "success";
       }else {
           return "推送出现了异常，详情可进入日志查看";
       }
    }
}
